package com.jeff.android.lab.module.widget.fragment;

import com.jeff.android.lab.BaseActivity;

/**
 * @author: dingfeng
 * @date: 2020-02-04
 * @since: 1.0.0
 **/
public class BackHandleFragmentActivity extends BaseActivity implements BackHandleInterface {


    BackFragment mBackFragment;

    @Override
    public void onSelectedFragment(BackFragment fragment) {
        mBackFragment = fragment;
    }

    @Override
    public void onBackPressed() {
        if (mBackFragment == null || mBackFragment.onBackPressed()) {
            if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
                super.onBackPressed();
            } else {
                getSupportFragmentManager().popBackStack();
            }
        }
    }

}
